var t = require("../../../../@babel/runtime/helpers/toConsumableArray"), a = getApp();

Page({
    data: {
        language: "",
        datas: [],
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        types: "5"
    },
    onLoad: function(t) {
        t.type && 1 == t.type ? (this.setData({
            types: "6"
        }), this._getData("6"), wx.setNavigationBarTitle({
            title: "无效佣金"
        })) : (this.setData({
            types: "5"
        }), this._getData("5"), wx.setNavigationBarTitle({
            title: "已提现佣金"
        }));
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.current_page >= this.data.total_page ? wx.showToast({
            title: "没有更多数据",
            icon: "none"
        }) : this.getMoreData();
    },
    onShareAppMessage: function() {},
    _getData: function(t) {
        var e = this, s = a.getNetAddresss("plugin.commission.api.commission.get-commission-list");
        s += "&commission_type=" + t, a._getNetWork({
            url: s,
            success: function(t) {
                var a = t.data;
                1 == a.result && (e.setData({
                    datas: a.data.data,
                    total_page: a.data.last_page,
                    current_page: a.data.current_page
                }), e.data.total_page || e.setData({
                    total_page: 0
                }));
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getMoreData: function() {
        var e = this, s = this.data.page;
        s += 1, this.setData({
            page: s
        });
        var o = a.getNetAddresss("plugin.commission.api.commission.get-commission-list");
        a._getNetWork({
            url: o,
            data: {
                page: e.data.page,
                commission_type: e.data.types
            },
            success: function(a) {
                var s = a.data;
                if (1 == s.result) {
                    var o = s.data.data, n = [].concat(t(e.data.datas), t(o));
                    e.setData({
                        datas: n,
                        total_page: s.data.last_page,
                        current_page: s.data.current_page
                    });
                }
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    }
});